home *** CD-ROM | disk | FTP | other *** search
- /*****************************************************************************
- ; :Module. misc.c
- ; :Author. Bert Jahn
- ; :EMail. wepl@whdload.org
- ; :Address. Franz-Liszt-Straße 16, Rudolstadt, 07404, Germany
- ; :Version. $Id: misc.c 1.2 2000/05/23 17:12:51 jah Exp $
- ; :History. 28.03.00 extracted from whdloadgci.c
- ; :Copyright. All Rights Reserved
- ; :Language. C
- ; :Translator. GCC
- ****************************************************************************/
-
- #include <stdio.h>
- #include <stdlib.h>
-
- #include "WHDLoadGCI.h"
-
- /****************************************************************************/
-
- /*
- * create string containing right aligned hexadecimal representation of value
- */
- STRPTR val2hexr(ULONG value) {
- static char s[12];
- sprintf(s,"\33r%s",val2hex(value));
- return s;
- }
-
- /*
- * create string containing right aligned hexadecimal representation of value
- */
- STRPTR val2hex64r(ULONG value1, ULONG value2) {
- static char s[20];
- if (value1) {
- sprintf(s,"\33r$%x%08x",value1,value2);
- return s;
- } else {
- return val2hexr(value2);
- }
- }
-
- /*
- * return string containing hexadecimal representation of value
- */
- STRPTR val2hex(ULONG value) {
- static char s[10];
- sprintf(s,value < 16 ? "%d" : "$%x",value);
- return s;
- }
-
- /*
- * create string for "String"
- */
- STRPTR val2hex4(UWORD val) {
- static char s[6];
- if (val < 16) {
- sprintf(s,"%d",val);
- } else {
- sprintf(s,"$%x",val);
- }
- return s;
- }
- STRPTR val2hex8(ULONG val) {
- static char s[10];
- if (val < 16) {
- sprintf(s,"%ld",val);
- } else {
- sprintf(s,"$%lx",val);
- }
- return s;
- }
- /*
- * create string for "Text"
- */
- STRPTR val2hex1t(UBYTE val) {
- static char s[3];
- sprintf(s,"\33r%ld",val);
- return s;
- }
- STRPTR val2hex4t(UWORD val) {
- static char s[6];
- if (val < 16) {
- sprintf(s,"\33r%d",val);
- } else {
- sprintf(s,"\33r$%x",val);
- }
- return s;
- }
- STRPTR val2hex8t(ULONG val) {
- static char s[10];
- if (val < 16) {
- sprintf(s,"\33r%ld",val);
- } else {
- sprintf(s,"\33r$%lx",val);
- }
- return s;
- }
- /*
- * set contents of "String"
- */
- void sethex4(APTR gad, UWORD val) {
- set(gad,MUIA_String_Contents,val2hex4(val));
- }
- void sethex8(APTR gad, ULONG val) {
- set(gad,MUIA_String_Contents,val2hex8(val));
- set(gad,MUIA_Text_Contents,val2hex8(val));
- }
- /*
- * set contents of "Text"
- */
- void sethex1t(APTR gad, UBYTE val) {
- set(gad,MUIA_Text_Contents,val2hex1t(val));
- }
- void sethex4t(APTR gad, UWORD val) {
- set(gad,MUIA_Text_Contents,val2hex4t(val));
- }
- void sethex8t(APTR gad, ULONG val) {
- set(gad,MUIA_Text_Contents,val2hex8t(val));
- }
-
-